package com.cdd.user.config;

import com.google.common.base.Predicates;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.service.VendorExtension;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;

import java.util.ArrayList;

@Configuration
public class SwaggerConfig {
 
        @Bean //swagger中所有的功能都封装在Docket类中
    public Docket docket() {
            Docket docket1 = new Docket(DocumentationType.SWAGGER_2)
                    .apiInfo(apiInfo())//设置api文档信息
                    .select()
                    //指定为哪些包下的类生成接口文档。
                    .paths(Predicates.not(PathSelectors.regex("/error")))
                    //设置那些请求路径生产接口文档
                    .paths(PathSelectors.any())
                    .build();
            return docket1;
        }
         //定义自己接口文档信息
        public ApiInfo apiInfo (){
            Contact DEFAULT_CONTACT = new Contact("管某人", "http://www.baidu.com", "171620711@qq.com");
            ApiInfo apiInfo = new ApiInfo("guan的在线文档", "这是最牛文档", "1.0", "http://www.jd.com",
                    DEFAULT_CONTACT, "志远科技", "http://www.taobao.com", new ArrayList<VendorExtension>());
            return apiInfo;
        }
 
}